<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="24">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
          label-width="120px">
          <el-form-item label="资产编号" prop="instrumentNumber">
            <el-input v-model="queryParams.instrumentNumber" placeholder="请输入资产编号" clearable
              @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item label="低值品编号" prop="lowValueNewProductNumber">
            <el-input v-model="queryParams.lowValueNewProductNumber" placeholder="请输入低值品编号" clearable
              @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item label="低值品名称" prop="lowValueNewProductName">
            <el-input v-model="queryParams.lowValueNewProductName" placeholder="请输入低值品名称" clearable
              @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item label="类别" prop="category">
            <el-input v-model="queryParams.category" placeholder="请输入类别" clearable @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item label="存放地" prop="storageLocation">
            <el-input v-model="queryParams.storageLocation" placeholder="请输入存放地" clearable
              @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item label="最新修订日期" prop="revisedTm">
            <el-date-picker v-model="queryParams.revisedTm" type="date" placeholder="选择最新修订时间" format="yyyy-MM-dd"
              value-format="yyyy-MM-dd" style="width: 100%;" clearable @change="handleDateChange" />
          </el-form-item>
          <el-form-item label="最新修订事由" prop="revisedReason">
            <el-input v-model="queryParams.revisedReason" placeholder="请输入最新修订事由" clearable
              @keyup.enter.native="handleQuery" />
          </el-form-item>
          <!-- <el-form-item label="最新修订人" prop="revisedPeople">
            <el-select v-model="queryParams.revisedPeople" placeholder="最新修订人" style="width: 100%;" disabled filterable clearable
              @change="handleQuery">
              <el-option v-for="dict in dict.type.user_code" :key="dict.value" :label="dict.label"
                :value="dict.value" />
            </el-select>
          </el-form-item> -->
          <el-form-item label="是否报废" prop="isscrap">
            <el-select v-model="queryParams.isscrap" placeholder="请选择" style="width: 100%;">
              <el-option label="是" value="是"></el-option>
              <el-option label="否" value="否"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="使用人" prop="users">
            <el-select v-model="queryParams.users" placeholder="使用人" style="width: 100%;" filterable clearable
              @change="handleQuery">
              <el-option v-for="dict in dict.type.user_code" :key="dict.value" :label="dict.label"
                :value="dict.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="保管人" prop="keeper">
            <el-select v-model="queryParams.keeper" placeholder="保管人" style="width: 100%;" filterable clearable
              @change="handleQuery">
              <el-option v-for="dict in dict.type.user_code" :key="dict.value" :label="dict.label"
                :value="dict.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="责任人" prop="responser">
            <el-select v-model="queryParams.responser" placeholder="责任人" style="width: 100%;" filterable clearable
              @change="handleQuery">
              <el-option v-for="dict in dict.type.user_code" :key="dict.value" :label="dict.label"
                :value="dict.value" />
            </el-select>
          </el-form-item>

          <!-- <el-form-item label="领用人" prop="recipient">
            <el-input v-model="queryParams.recipient" placeholder="请输入领用人" clearable
              @keyup.enter.native="handleQuery" />
          </el-form-item> -->
          <!-- <el-form-item label="报废时间" prop="transferTm">
            <el-date-picker v-model="form.transferTm" type="date" placeholder="选择报废时间" format="yyyy-MM-dd"
              value-format="yyyy-MM-dd" clearable />
          </el-form-item> -->
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>


    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['system:dinai:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['system:dinai:edit']">修改</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:dinai:remove']"
        >删除</el-button>
      </el-col> -->
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['system:dinai:export']">导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-upload" size="mini" @click="handleImport"
          v-hasPermi="['system:dinai:batchadd']">批量新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-upload" size="mini" @click="handleUpdateImport"
          v-hasPermi="['system:dinai:batchedit']">批量修改</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="dinaiList" highlight-current-row @selection-change="handleSelectionChange" class="custom-table">
      <el-table-column type="selection" width="55" align="center" />

      
      <el-table-column label="低值品编号(主)" align="center"width="155" prop="lowValueNewProductNumber">
        <template slot-scope="scope">
          <el-link type="success" v-if="scope.row.changeSize > 0"
            @click="() => numberNo4ChangeListDialog = scope.row.lowValueNewProductNumber" style="font-family: '楷体', KaiTi, STKaiti, serif;">
            {{ scope.row.lowValueNewProductNumber }}
          </el-link>
          <span v-else> {{ scope.row.lowValueNewProductNumber }}</span>

        </template>
      </el-table-column>
      <el-table-column label="低值品名称" align="center" width="155"prop="lowValueNewProductName">
        <template v-slot="scope">
          <el-link v-if="scope.row.lowValueNewProductName" :type="scope.row.pictureUrl ? 'primary' : 'warning'"
            @click="uploadPicture(scope.row)">{{
              scope.row.lowValueNewProductName }}</el-link>
        </template>
      </el-table-column>
      <el-table-column label="存放地" align="center" width="155"prop="storageLocation" />
      <el-table-column label="使用人" align="center" width="155"prop="users">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.user_code" :value="scope.row.users" />
        </template>
      </el-table-column>
      <el-table-column label="保管人" align="center"width="155" prop="keeper">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.user_code" :value="scope.row.keeper" />
        </template>
      </el-table-column>
      <el-table-column label="责任人" align="center" width="155"prop="responser">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.user_code" :value="scope.row.responser" />
        </template>
      </el-table-column>
      <el-table-column label="历史责任人" align="center" width="155"prop="responserHistory">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.user_code" :value="scope.row.responserHistory" />
        </template>
      </el-table-column>
      <el-table-column label="资产编号" align="center" width="155"prop="instrumentNumber" />
      <el-table-column label="类别" align="center"width="155" prop="category" />
    
      <el-table-column label="最新修订时间" align="center" width="155"prop="revisedTm" />
      <el-table-column label="最新修订事由" align="center"width="155" prop="revisedReason" />
      <el-table-column label="最新修订人" align="center" width="155"prop="revisedPeople">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.user_code" :value="scope.row.revisedPeople" />
        </template>
      </el-table-column>
      <el-table-column label="是否报废" align="center"width="155" prop="isscrap" />
      <el-table-column label="型号" align="center" width="155"prop="model" />
      <el-table-column label="规格" align="center" width="155"prop="specifications" />
      <el-table-column label="数量" align="center" width="155"prop="quantity" />
      <el-table-column label="单价" align="center" width="155"prop="price" />
      <el-table-column label="金额" align="center" width="155"prop="amount" />
      <el-table-column label="厂家" align="center" width="155"prop="manufacturer" />
      <el-table-column label="购置日期" align="center" width="155"prop="acquisitionDate" />
      <el-table-column label="供货商" align="center"width="155" prop="supplier" />
      <el-table-column label="备注" align="center" width="155"prop="remark" />
      <el-table-column label="领用人" align="center" width="155"prop="recipient" />
      <el-table-column label="报废时间" align="center" width="155"prop="transferTm" />
      <el-table-column label="领用单位号" align="center" width="155"prop="receivingNumber" />
      <el-table-column label="领用单位名" align="center" width="155"prop="receivingName" />
      <!-- <el-table-column label="备用字段1" align="center" prop="backupFields1" />
      <el-table-column label="备用字段2" align="center" prop="backupFields2" />
      <el-table-column label="备用字段3" align="center" prop="backupFields3" />
      <el-table-column label="备用字段4" align="center" prop="backupFields4" />
      <el-table-column label="备用字段5" align="center" prop="backupFields5" />
      <el-table-column label="备用字段6" align="center" prop="backupFields6" />
      <el-table-column label="备用字段7" align="center" prop="backupFields7" />
      <el-table-column label="备用字段8" align="center" prop="backupFields8" />
      <el-table-column label="备用字段9" align="center" prop="backupFields9" />
      <el-table-column label="备用字段10" align="center" prop="backupFields10" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['system:dinai:edit']">修改</el-button>
          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:dinai:remove']"
          >删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改低耐资产对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
 

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="资产编号" prop="instrumentNumber">
              <el-input v-model="form.instrumentNumber" placeholder="请输入资产编号" :disabled="!!form.id" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="类别" prop="category">
              <el-input v-model="form.category" placeholder="请输入类别" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="低值品编号(主)" prop="lowValueNewProductNumber">
              <el-input v-model="form.lowValueNewProductNumber" placeholder="请输入低值品编号" :disabled="!!form.id" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="低值品名称" prop="lowValueNewProductName">
              <el-input v-model="form.lowValueNewProductName" placeholder="请输入低值品名称" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="存放地" prop="storageLocation">
              <el-input v-model="form.storageLocation" placeholder="请输入存放地" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="最新修订事由" prop="revisedReason">
              <el-input type="textarea" :rows="1" v-model="form.revisedReason" placeholder="请输入最新修订事由" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="最新修订人" prop="revisedPeople">
              <el-select v-model="form.revisedPeople" placeholder="" style="width: 100%;"disabled filterable clearable >
                <el-option v-for="dict in dict.type.user_code" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最新修订日期" prop="revisedTm">
              <el-date-picker v-model="form.revisedTm" type="date" placeholder="选择最新修订时间" format="yyyy-MM-dd"
                value-format="yyyy-MM-dd" style="width: 100%;" clearable  @change="handleDateChange"/>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="是否报废" prop="isscrap">
              <el-select v-model="form.isscrap" placeholder="请选择是否已报废" style="width: 100%;">
                <el-option label="是" value="是"></el-option>
                <el-option label="否" value="否"></el-option>
              </el-select>
            </el-form-item>

          </el-col>

          <el-col :span="12">
           


              <el-form-item label="报废时间" prop="transferTm">
              <el-date-picker v-model="form.transferTm" type="date" placeholder="请输入报废时间" format="yyyy-MM-dd"
                value-format="yyyy-MM-dd" style="width: 100%;" clearable />
            </el-form-item>
           
          </el-col>
 
        </el-row>

        <el-row :gutter="20">
        <el-col :span="12">
            <el-form-item label="使用人" prop="users">
              <el-select v-model="form.users" placeholder="使用人" style="width: 100%;" filterable clearable>
                <el-option v-for="dict in dict.type.user_code" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="保管人" prop="keeper">
              <el-select v-model="form.keeper" placeholder="保管人" style="width: 100%;" filterable clearable>
                <el-option v-for="dict in dict.type.user_code" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="责任人" prop="responser">
              <el-select v-model="form.responser" placeholder="责任人" style="width: 100%;" filterable clearable>
                <el-option v-for="dict in dict.type.user_code" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="历史责任人" prop="responserHistory">
              <el-input v-model="form.responserHistory" placeholder="请输入历史责任人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="型号" prop="model">
              <el-input v-model="form.model" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="规格" prop="specifications">
              <el-input v-model="form.specifications" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="数量" prop="quantity">
              <el-input v-model="form.quantity" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="单价" prop="price">
              <el-input v-model="form.price" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="金额" prop="amount">
              <el-input v-model="form.amount" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="厂家" prop="manufacturer">
              <el-input v-model="form.manufacturer" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="购置日期" prop="acquisitionDate">
              <el-input v-model="form.acquisitionDate" placeholder="请输入内容" />
            </el-form-item>
          </el-col> -->
        </el-row>

        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="供货商" prop="supplier">
              <el-input v-model="form.supplier" placeholder="请输入内容" />
            </el-form-item>
          </el-col>

        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" :rows="1" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-row>

        <!-- <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="领用人" prop="recipient">
              <el-input v-model="form.recipient" placeholder="请输入领用人" />
            </el-form-item>
          </el-col> -->
     
        <!-- </el-row> -->

        <!-- <el-form-item label="备用字段1" prop="backupFields1">
          <el-input v-model="form.backupFields1" placeholder="请输入备用字段1" />
        </el-form-item>
        <el-form-item label="备用字段2" prop="backupFields2">
          <el-input v-model="form.backupFields2" placeholder="请输入备用字段2" />
        </el-form-item>
        <el-form-item label="备用字段3" prop="backupFields3">
          <el-input v-model="form.backupFields3" placeholder="请输入备用字段3" />
        </el-form-item>
        <el-form-item label="备用字段4" prop="backupFields4">
          <el-input v-model="form.backupFields4" placeholder="请输入备用字段4" />
        </el-form-item>
        <el-form-item label="备用字段5" prop="backupFields5">
          <el-input v-model="form.backupFields5" placeholder="请输入备用字段5" />
        </el-form-item>
        <el-form-item label="备用字段6" prop="backupFields6">
          <el-input v-model="form.backupFields6" placeholder="请输入备用字段6" />
        </el-form-item>
        <el-form-item label="备用字段7" prop="backupFields7">
          <el-input v-model="form.backupFields7" placeholder="请输入备用字段7" />
        </el-form-item>
        <el-form-item label="备用字段8" prop="backupFields8">
          <el-input v-model="form.backupFields8" placeholder="请输入备用字段8" />
        </el-form-item>
        <el-form-item label="备用字段9" prop="backupFields9">
          <el-input v-model="form.backupFields9" placeholder="请输入备用字段9" />
        </el-form-item>
        <el-form-item label="备用字段10" prop="backupFields10">
          <el-input v-model="form.backupFields10" placeholder="请输入备用字段10" />
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url"
        :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess"
        :auto-upload="false" drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!-- <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
          </div> -->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
            @click="handleExportTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <PropertyPictureUpload :id.sync="id4ShebeiDialog" :propertyName.sync="propertyName4ShebeiDialog"
      :propertyType.sync="propertyTypeShebeiDialog" :pictureUrl.sync="pictureUrl4ShebeiDialog"
      @close="closeDialogRefresh" />
    <ChangeListDialog :numberNo.sync="numberNo4ChangeListDialog" type="2" />

  </div>
</template>

<script>
import { listDinai, getDinai, delDinai, addDinai, updateDinai } from "@/api/system/dinai";
import { getToken } from "@/utils/auth";
import PropertyPictureUpload from '@/components/My/Property/property-picture-dialog.vue';
import ChangeListDialog from '@/components/My/Property/change-list-dialog.vue';


export default {
  components: {
    PropertyPictureUpload, ChangeListDialog
  },
  dicts: ['user_code'],
  name: "Dinai",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 低耐资产表格数据
      dinaiList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        receivingNumber: null,
        receivingName: null,
        instrumentNumber: null,
        lowValueNewProductNumber: null,
        lowValueNewProductName: null,
        category: null,
        storageLocation: null,
        revisedTm: null,
        revisedReason: null,
        revisedPeople: null,
        isscrap: null,
        users: null,
        keeper: null,
        responser: null,
        responserHistory: null,
        model: null,
        specifications: null,
        quantity: null,
        price: null,
        amount: null,
        manufacturer: null,
        acquisitionDate: null,
        supplier: null,
        recipient: null,
        transferTm: null
        // backupFields1: null,
        // backupFields2: null,
        // backupFields3: null,
        // backupFields4: null,
        // backupFields5: null,
        // backupFields6: null,
        // backupFields7: null,
        // backupFields8: null,
        // backupFields9: null,
        // backupFields10: null
      },
      // 表单参数
      form: {revisedTm:'',},
      // 表单校验
      rules: {
        lowValueNewProductNumber: [
          { required: true, message: "低值品编号不能为空", trigger: "blur" }
        ],
        lowValueNewProductName: [
          { required: true, message: "低值品名称不能为空", trigger: "blur" }
        ],
        instrumentNumber: [
          { required: true, message: "资产编号不能为空", trigger: "blur" }
        ],
        revisedReason: [
          { required: true, message: "最新修订是由不能为空", trigger: "blur" }
        ],
        storageLocation:[
          { required: true, message: "存放地不能为空", trigger: "blur" }
        ],
      },
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: '',
        templateUrl: ''
      },
      id4ShebeiDialog: 0,
      propertyName4ShebeiDialog: '',
      propertyTypeShebeiDialog: '',
      pictureUrl4ShebeiDialog: '',
      numberNo4ChangeListDialog: ''

    };
  },
  created() {
    this.getList();
    if (!this.form.revisedTm) {
      this.form.revisedTm = this.getCurrentDate();
    }
  },
  methods: {
    /** 查询低耐资产列表 */
    getList() {
      this.loading = true;
      listDinai(this.queryParams).then(response => {
        this.dinaiList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        receivingNumber: null,
        receivingName: null,
        instrumentNumber: null,
        lowValueNewProductNumber: null,
        lowValueNewProductName: null,
        category: null,
        storageLocation: null,
        revisedTm: this.getCurrentDate(),
        revisedReason: null,
        revisedPeople: null,
        isscrap: null,
        users: null,
        keeper: null,
        responser: null,
        responserHistory: null,
        model: null,
        specifications: null,
        quantity: null,
        price: null,
        amount: null,
        manufacturer: null,
        acquisitionDate: null,
        supplier: null,
        remark: null,
        recipient: null,
        transferTm: null
        // backupFields1: null,
        // backupFields2: null,
        // backupFields3: null,
        // backupFields4: null,
        // backupFields5: null,
        // backupFields6: null,
        // backupFields7: null,
        // backupFields8: null,
        // backupFields9: null,
        // backupFields10: null
      };
      this.resetForm("form");
    },

    handleDateChange(val) {
      // 如果清空了日期，自动设置为今天
      if (!val) {
        this.form.revisedTm = this.getCurrentDate();
      }
    },
    getCurrentDate() {
      const today = new Date();
      const year = today.getFullYear();
      const month = String(today.getMonth() + 1).padStart(2, '0');
      const day = String(today.getDate()).padStart(2, '0');
      return `${year}-${month}-${day}`;
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加低耐资产";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
  this.reset(); // 先调用reset确保有默认值
  const id = row.id || this.ids;
  getDinai(id).then(response => {
    // 保留原有数据，但确保revisedTm有值
    this.form = {
      ...response.data,
      revisedTm: response.data.revisedTm || this.getCurrentDate()
    };
    this.open = true;
    this.title = "修改低耐资产";
  });
},
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateDinai(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addDinai(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除低耐资产编号为"' + ids + '"的数据项？').then(function () {
        return delDinai(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/dinai/export', {
        ...this.queryParams
      }, `dinai_${new Date().getTime()}.xlsx`)
    },

    /** 批量新增按钮操作 */
    handleImport() {
      this.upload.title = "低耐资产批量新增";
      this.upload.updateSupport = false;
      this.upload.url = process.env.VUE_APP_BASE_API + "/system/dinai/importData";
      this.upload.templateUrl = 'system/dinai/importTemplate',
        this.upload.open = true;
    },

    /** 批量修改按钮操作 */
    handleUpdateImport() {
      this.upload.title = "低耐资产批量修改";
      this.upload.updateSupport = true;
      this.upload.url = process.env.VUE_APP_BASE_API + "/system/dinai/batchUpload";
      this.upload.templateUrl = 'system/dinai/getBatchEditImportTemplate',
        this.upload.open = true;
    },
    /** 下载模板操作 */
    handleExportTemplate() {
      this.download(this.upload.templateUrl, {
      }, `${this.upload.title}_${new Date().getTime()}.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    submitFileForm() {
      this.$refs.upload.submit();
    },
    uploadPicture(row) {
      this.id4ShebeiDialog = row.id;
      this.propertyName4ShebeiDialog = row.lowValueNewProductName + '';
      this.propertyTypeShebeiDialog = '2';
      this.pictureUrl4ShebeiDialog = row.pictureUrl + '';
    },
    /** 关闭弹窗刷新列表 */
    closeDialogRefresh(isRefresh) {
      if (isRefresh) {
        this.getList();
      }
    },


  }
};
</script>
<style scoped>
/* 自定义表格样式 */
.custom-table {
  /* 设置表格整体滚动条样式 */
  ::-webkit-scrollbar {
    width: 8px;  /* 垂直滚动条宽度 */
    height: 8px; /* 水平滚动条高度 */
  }
  
  /* 滚动条轨道 */
  ::-webkit-scrollbar-track {
    background: #c0bec5;
    border-radius: 4px;
  }
  
  /* 滚动条滑块 */
  ::-webkit-scrollbar-thumb {
    background: #1d77c5;
    border-radius: 4px;
  }
  
  /* 滚动条滑块悬停效果 */
  ::-webkit-scrollbar-thumb:hover {
    background: #942828;
  }
  
  /* 特别针对表格底部滚动条 */
  .el-table__body-wrapper::-webkit-scrollbar {
    height: 15px; /* 调整底部滚动条粗细 */
  }
  
  .el-table__body-wrapper::-webkit-scrollbar-thumb {
    background-color: #888;
  }
}
</style>